home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ccdl150l.zip / IO / FREAD.C < prev    next >
C/C++ Source or Header  |  1997-02-27  |  493b  |  25 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <libp.h>
  6.  
  7. size_t fread(void *buf, size_t size, size_t count, FILE *stream)
  8. {
  9.     int rv;
  10.     int len = count * size,i;
  11.     char *lbuf = buf;
  12.     if (stream->token != FILTOK)
  13.         return 0;
  14.     if (!(stream->flags & _F_READ)) {
  15.         stream->flags |= _F_ERR;
  16.         return 0;
  17.     }
  18.     for (i=0; i < len; i++) {
  19.         rv = _basegetc(stream);
  20.         if (rv == EOF)
  21.             return i / size;
  22.         *lbuf++ = (char) rv;
  23.     }
  24.     return count;
  25. }